#! /usr/bin/env python3
# coding: utf-8
# author: maxiao
# date: 2023-04-16 22:44
# description: 测试chromedriver的有效性

import time

from selenium import webdriver
from selenium.webdriver.common.by import By

# 设置游览器相关特性
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches",
    ["enable-automation", "enable-logging"])
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.baidu.com")
driver.implicitly_wait(3)
# 输入需要检索的文本
driver.find_element(By.ID, 'kw').send_keys('linux')
# 点击搜索按钮
driver.find_element(By.ID, 'su').click()
time.sleep(3)
# 退出
driver.quit()
